
/*
 * Karvaly.DOM.KeyEvent
 * depends: Karvaly.DOM.Event
 */
Karvaly.DOM.KeyEvent = (function() {
    
    // imports
    var Class = Karvaly.Class;
    var Event = Karvaly.DOM.Event;
    
    // class
    var KeyEvent = new Class(Event, {
	constructor : function(event) {
	    this.initKeyEvent(event);
	},
	initKeyEvent : function(event) {
	    if (!event) return;
	    this.initEvent(event);
	    var type = this.type;
	    if (type === 'keypress') {
		this.fromChar = String.fromCharCode(this.charCode = event.charCode || event.keyCode);
	    } else if (type === 'keyup' || type === 'keydown') {
		this.fromChar = String.fromCharCode(this.keyCode = event.keyCode);
	    }
	}
    });
    
    return KeyEvent;
    
})();
